package questions;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

import libraries.csvreader.CSVReader;

public class QuestionLoader {
	private ArrayList<Question> questions;
	
	public QuestionLoader(String file) {
		questions = new ArrayList<Question>();
		CSVReader reader = null;
		try {
			reader = new CSVReader(new FileReader(file+".csv"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	    String [] nextLine;
	    int numQ = 0;
	    try {
			while ((nextLine = reader.readNext()) != null) {
			    Question q = new Question(nextLine[1], numQ, nextLine[0]);
			    questions.add(q);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	    Collections.shuffle(questions);
	}

	public ArrayList<Question> getQuestions() {
		return this.questions;
	}
}
